
    /**  
    * @Title: WSGatewayServiceImterceptor.java
    * @Package com.efast.cafe.commponent.es.webservice.interceptor
    * @Description: TODO(用一句话描述该文件做什么)
    * @author Administrator
    * @date 2018年10月20日
    * @version V1.0  
    */
    
package com.efast.cafe.commponent.es.webservice.interceptor;

import javax.servlet.http.HttpServletRequest;

import org.apache.cxf.binding.soap.SoapMessage;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
import org.apache.cxf.transport.http.AbstractHTTPDestination;
import org.slf4j.MDC;

import com.efast.cafe.util.IpAddressUtil;

/**
    * @ClassName: WSGatewayServiceImterceptor
    * @Description: TODO(这里用一句话描述这个类的作用)
    * @author Administrator
    * @date 2018年10月20日
    *
    */

public class WSGatewayServiceInterceptor extends AbstractPhaseInterceptor<SoapMessage>{

	
	    /* (非 Javadoc)
	    * 
	    * 
	    * @param message
	    * @throws Fault
	    * @see org.apache.cxf.interceptor.Interceptor#handleMessage(org.apache.cxf.message.Message)
	    */
	    
	
	    /**
	     * 创建一个新的实例 WSGatewayServiceInterceptor.
	     *
	     * @param phase
	     */
	    
	public WSGatewayServiceInterceptor() {
		super(Phase.PRE_INVOKE);
	}

	@Override
	public void handleMessage(SoapMessage message) throws Fault {
		HttpServletRequest request = (HttpServletRequest) message
				.get(AbstractHTTPDestination.HTTP_REQUEST);
		MDC.put("clientIP",IpAddressUtil.getIpAdrress(request));
	}

}
